package com.zy.qudadid.ui.fragment;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.zy.lcpassenger.R;
import com.zy.qudadid.model.IntegralOther;
import com.zy.qudadid.model.Shop;
import com.zy.qudadid.presenter.IntegralOtherPresenter;
import com.zy.qudadid.presenter.ShopPresenter;
import com.zy.qudadid.ui.activity.base.RecycleViewFragment;
import com.zy.qudadid.ui.activity.base.SwipeRecycleViewFragment;
import com.zy.qudadid.ui.adapter.IntegralOtherAdapter;
import com.zy.qudadid.ui.adapter.IntegralOtherAdapter3;
import com.zy.qudadid.ui.adapter.ShopAdapter;
import com.zy.qudadid.ui.view.IntegralOtherView;
import com.zy.qudadid.ui.view.ShopView;
import com.zy.qudadid.utils.AESCrypt;
import com.zy.qudadid.utils.StringUtil;
import com.zy.qudadid.utils.UserUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import butterknife.Bind;

/**
 * Created by liuchao on 2017/4/10.
 */

/**
 * 兑换记录
 */
public class IntegralOther3Fragment extends RecycleViewFragment<IntegralOtherPresenter,IntegralOtherAdapter3,IntegralOther> implements IntegralOtherView {

    @Bind(R.id.txtTitle)
    TextView txtTitle;

    private ArrayList<IntegralOther> list;

    @Override
    protected IntegralOtherAdapter3 provideAdapter() {
        return new IntegralOtherAdapter3(getContext());
    }

    @Override
    protected RecyclerView.LayoutManager provideLayoutManager() {
        return new LinearLayoutManager(getContext());
    }

    @Override
    public void initListeners() {

    }

    @Override
    protected String provideTitle() {
        return "";
    }

    @Override
    protected void initThings(View view) {
        super.initThings(view);

        txtTitle.setText("兑换明细");

        list = new ArrayList<>();
//        list.add(new IntegralOther());
//        list.add(new IntegralOther());
//        list.add(new IntegralOther());
//        list.add(new IntegralOther());
//        list.add(new IntegralOther());
//        list.add(new IntegralOther());
//        list.add(new IntegralOther());
//        list.add(new IntegralOther());
//        list.add(new IntegralOther());
//        list.add(new IntegralOther());
//        list.add(new IntegralOther());
//        bd(list);


    }

    @Override
    public void onResume() {
        super.onResume();

        Map<String,String> map = new HashMap<>();
        map.put("user_id",new UserUtil(getContext()).getUserId());
        String json = StringUtil.toJson(map);
        try {
            String data1 = AESCrypt.getInstance().encrypt(json);
            String d = StringUtil.replaceBlank(data1);
            presenter.getIntegral(d,2);
        } catch (Exception ex) {
        }
    }

    @Override
    public int provideLayoutId() {
        return R.layout.fragment_integralother;
    }

    @Override
    public IntegralOtherPresenter createPresenter() {
        return new IntegralOtherPresenter();
    }

    @Override
    public void onItemClick(View view, int pos, IntegralOther item) {

    }

    @Override
    public void integralSuccess(ArrayList<IntegralOther> data) {
        bd(data);
    }

    @Override
    public void integralError(String str) {
        toast(str);
    }
}
